package com.v5ba.openapi;

import org.springframework.aop.aspectj.AspectJExpressionPointcut;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author yiren
 * @since 2022/7/8
 */
@Configuration
public class MyConfiguration {
    public static final String traceExecution = "@annotation(com.v5ba.openapi.OpenAPI)";

    @Bean
    public OpenAPIProperties getOpenAPIProperties(){
        return new OpenAPIProperties();
    }
    @Bean
    public DefaultPointcutAdvisor defaultPointcutAdvisor(OpenAPIProperties openAPIProperties) {
        DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor();
        AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
        pointcut.setExpression(traceExecution);
        advisor.setPointcut(pointcut);
        advisor.setAdvice(new MyAdvice(openAPIProperties));
        return advisor;
    }
}
